import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:hello_plugin/hello_plugin.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _test = "test";

  @override
  void initState() {
    super.initState();
    initPlatformState();
    testChannel();
  }

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion =
          await HelloPlugin.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  testChannel() async {
   var test = await HelloPlugin.getImage;
   setState(() {
     _test = test;
   });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Column(
            children: [
              Text(
                'Method1: $_platformVersion\n',
                style: TextStyle(fontSize: 20),
              ),
              Text(
                'Method2: $_test\n',
                style: TextStyle(fontSize: 20),
              ),
            ],
          )),
    );
  }
}
